package com.jwl.idc.activity;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.jwl.idc.R;
import com.jwl.idc.customview.DialogCreater;
import com.jwl.idc.customview.TitleBar;
import com.jwl.idc.http.HttpAction;
import com.jwl.idc.http.HttpToViewInterface;

public class BaseActivity extends Activity implements DialogInterface.OnClickListener {


    public static final int LOGIN_DIALOG = 0x001;
    public static final int REGISER_USER_DIALOG = 0x002;
    public static final int SMS_DIALOG = 0x003;

    public HttpAction action = null;
    public HttpToViewInterface httpToviewCallBack= null;
    public TitleBar titlebar;
    public LayoutInflater myInflater;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//			getWindow().addFlags(
//					WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        myInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }


    public void showWaitDialog(int dialogId, String str) {
        View view = myInflater.inflate(R.layout.progress_dialog_view, null);
        ((TextView) view.findViewById(R.id.pg_message)).setText(str);
        DialogCreater.showDialog(this, null, null, view, this, this, dialogId,
                null, null).show();
    }
    public void closeWaitDialog(int dialogId) {
        DialogCreater.closeDialog(dialogId);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        close();
        System.gc();
    }


    //关闭相关的资源
    void close(){
        httpToviewCallBack = null;
        if(action != null)
            action.close();
        myInflater = null;
        titlebar = null;
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {

    }
}
